################################################################################
##
## Mod Title:		Advanced Visual Confirmation
## Mod Author:		AmigaLink < webmaster@amigalink.de > (Markus Schmidt) http://www.EssenMitFreude.info
##
## Mod Description:	This MOD replaces the original CAPTCHA of the phpBB Visual Confirmation.
##			
## Mod Version:		1.2.0
##
##
## Compatibility:	phpBB >= 2.0.11
##			(This installation guide is for phpBB 2.0.21)
##			(If you uses an older phpBB you should urgently update!!!)
##
## Installation Level:	Easy 
## Installation Time:	4 Minutes 
##
## Files To Edit:	5
##			profile.php
##			includes/constants.php
##			includes/functions.php
##			includes/usercp_register.php
##			templates/subSilver/profile_add_body.tpl
##
## Included Files:	5
##			admin/admin_captcha_config.php
##			includes/usercp_confirm.php
##			language/lang_english/lang_admin_captcha.php
##			language/lang_german/lang_admin_captcha.php
##			templates/subSilver/admin/admin_captcha_config.tpl
##
################################################################################
##
##  The following sites also contain the latest version of this MOD: 
## 
##  http://www.AmigaLink.de
##  http://www.phpBB.de
##  http://www.phpBBhacks.com
## 
##  Full support for this MOD can be obtained at: 
##
##  http://www.AmigaLink.de
##
################################################################################
##
##   2006-11-12 - Version 1.2.0
##	- configurable example code for ACP added
##	- background image funktions added
##	- better way to calculate letter size, position and color
##	- chess is now a real chess, with random position and rectangle size
##	- some code changes
##	- second preview and AVC version info added to ACP
##
##   2006-06-21 - Version 1.1.1
##	- add coincidence-generated variable code lengthens 
##
##   2006-03-30 - Version 1.1.0
##	- some colors changed for better recognition
##	- random font per letter added (idea by cYbercOsmOnauT)
##	- a security change
##	- some codechanges for higher CAPTCHA security
##	  ^ some colors changed
##	  ^ shuffle the defined colors before take one (by cYbercOsmOnauT)
##	  ^ better way to calculate letter size and position (partly based on an idea of cYbercOsmOnauT)
##	- add possibility to generate JPEG with adjustable quality 
##	- chess, ellipses, arcs and lines now can defined as random
##	- better way to position the shadow letters
##	- adjustable lattice color
##	- own lang files added
##	- now compatibly with servers which need a absolut path to load TTFonts
##
##   2006-03-16 - Version 1.0.1
##	- missing files added
##
##   2006-03-15 - Version 1.0.0
##	- first release
##
################################################################################
##
##  This hack is released under the GPL License. 
##  This hack can be freely used, but not distributed, without permission.
##  Intellectual Property Rights are retained by the hack author(s) 
##  listed above.
##
################################################################################
##
##  BEFORE ADDING THIS HACK TO YOUR FORUM, please be sure to backup ALL
##  affected files.
##
################################################################################
#
#-----[ PLEASE NOTE ]------------------------------------------
#
# At least GD library 1.6 with freetype are needed!
# For JPEG are GD 1.8 needed.
# Deactivate the Ellipses if you have PHP lower than 4.0.6.
#
#
#-----[ COPY FILES ]------------------------------------------
#
#  Copy / upload the following files to your phpBB root directory.
#  The phpBB root directory is the directory on your server containing index.php
#

admin/admin_captcha_config.php to admin/admin_captcha_config.php
includes/usercp_confirm.php to includes/usercp_confirm.php
language/lang_english/lang_admin_captcha.php to language/lang_english/lang_admin_captcha.php
language/lang_german/lang_admin_captcha.php to language/lang_german/lang_admin_captcha.php
templates/subSilver/admin/admin_captcha_config.tpl to templates/subSilver/admin/admin_captcha_config.tpl
captcha/fonts/* to captcha/fonts/*

#
#----------[ SQL ]--------------------------------------
#
#  Run the following SQL statement to update your phpBB database.
#  You can use phpMyAdmin or a similar tool to run this update.
#
#  IMPORTANT: If you have changed the table prefix from the default of phpBB2,
#  please be sure to replace phpbb with your prefix BEFORE running this update.
#

CREATE TABLE `phpbb_captcha_config` (
  `config_name` varchar(255) NOT NULL default '',
  `config_value` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`config_name`)
) TYPE=MyISAM;

INSERT INTO `phpbb_captcha_config` VALUES ('width', '350');
INSERT INTO `phpbb_captcha_config` VALUES ('height', '90');
INSERT INTO `phpbb_captcha_config` VALUES ('exsample_code', 'SAMPLE');
INSERT INTO `phpbb_captcha_config` VALUES ('background_color', '#E5ECF9');
INSERT INTO `phpbb_captcha_config` VALUES ('jpeg', '0');
INSERT INTO `phpbb_captcha_config` VALUES ('jpeg_quality', '50');
INSERT INTO `phpbb_captcha_config` VALUES ('pre_letters', '0');
INSERT INTO `phpbb_captcha_config` VALUES ('pre_letters_great', '0');
INSERT INTO `phpbb_captcha_config` VALUES ('font', '0');
INSERT INTO `phpbb_captcha_config` VALUES ('trans_letters', '0');
INSERT INTO `phpbb_captcha_config` VALUES ('chess', '0');
INSERT INTO `phpbb_captcha_config` VALUES ('ellipses', '1');
INSERT INTO `phpbb_captcha_config` VALUES ('arcs', '0');
INSERT INTO `phpbb_captcha_config` VALUES ('lines', '1');
INSERT INTO `phpbb_captcha_config` VALUES ('image', '0');
INSERT INTO `phpbb_captcha_config` VALUES ('bg_transition', '25');
INSERT INTO `phpbb_captcha_config` VALUES ('gammacorrect', '0.8');
INSERT INTO `phpbb_captcha_config` VALUES ('foreground_lattice_x', '15');
INSERT INTO `phpbb_captcha_config` VALUES ('foreground_lattice_y', '15');
INSERT INTO `phpbb_captcha_config` VALUES ('lattice_color', '#FFFFFF');
INSERT INTO `phpbb_captcha_config` VALUES ('avc_version', '1.2.0');

ALTER TABLE `phpbb_confirm` CHANGE `code` `code` CHAR(10) NOT NULL;

#
#----------[ OPEN ]-------------------------------------
#

profile.php

#
#----------[ FIND ]-------------------------------------
#

	else if ( $mode == 'confirm' )
	{
		// Visual Confirmation
		if ( $userdata['session_logged_in'] )

#
#----------[ REPLACE WITH ]-----------------------------
#

	else if ( $mode == 'confirm' )
	{
		// Visual Confirmation
		if ( $userdata['session_logged_in'] && (htmlspecialchars($HTTP_GET_VARS['id']) != 'Admin'))

#
#----------[ OPEN ]-------------------------------------
#

inculdes/constants.php

#
#----------[ FIND ]-------------------------------------
#

define('CONFIG_TABLE', $table_prefix.'config');

#
#----------[ AFTER, ADD ]-------------------------------
#

define('CAPTCHA_CONFIG_TABLE', $table_prefix.'captcha_config');

#
#----------[ OPEN ]-------------------------------------
#

includes/functions.php

#
#----------[ FIND ]-------------------------------------
#

		include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx);

#
#----------[ AFTER, ADD ]-------------------------------
#

		include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin_captcha.' . $phpEx);

#
#----------[ OPEN ]-------------------------------------
#

includes/usercp_register.php

#
#----------[ FIND ]-------------------------------------
#

		// Generate the required confirmation code
		// NB 0 (zero) could get confused with O (the letter) so we make change it
		$code = dss_rand();
		$code = substr(str_replace('0', 'Z', strtoupper(base_convert($code, 16, 35))), 2, 6);

#
#----------[ REPLACE WITH ]-----------------------------
#

		// Generate the required confirmation code
		$code_length = mt_rand(4, 6);
		$code = dss_rand();
		$code = strtoupper(base_convert($code, 16, 35));
		$code = str_replace('I', '', $code); // The letter I could get confused with the letter J and the number 1 (one) so we remove it
		$code = str_replace('0', '', $code); // NB 0 (zero) could get confused with O (the letter) so we remove it
		$code = substr($code, 2, $code_length);

#
#----------[ OPEN ]-------------------------------------
#

templates/subSilver/profile_add_body.tpl

#
#----------[ FIND ]-------------------------------------
#

	  <td class="row2"><input type="text" class="post" style="width: 200px" name="confirm_code" size="6" maxlength="6" value="" /></td>

#
#----------[ REPLACE WITH ]-----------------------------
#

	  <td class="row2"><input type="text" class="post" style="width: 200px" name="confirm_code" size="10" maxlength="10" value="" /></td>

#
#----------[ SAVE AND CLOSE ALL FILES ]-----------------
#
# EoM